package 自然排序Comparable的使用;

import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Student> ts=new TreeSet<Student>();
        Student s1=new Student("shihaoqing",21);
        Student s2=new Student("zhangpeng",23);
        Student s3=new Student("jiayueyue",22);
        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        for (Student s:ts){
            System.out.println(s.getName()+","+s.getAge());
        }
    }
}
